package com.hongyuan.sellfitness.ui.message.activity;

import android.os.Bundle;

import androidx.lifecycle.ViewModelProviders;

import com.hongyuan.sellfitness.R;
import com.hongyuan.sellfitness.base.AppViewModelFactory;
import com.hongyuan.sellfitness.base.Constants;
import com.hongyuan.sellfitness.base.CustomActivity;
import com.hongyuan.sellfitness.databinding.ActivityMsgDetailBinding;
import com.hongyuan.sellfitness.ui.message.view_mode.MsgDetailViewModel;

import me.tatarka.bindingcollectionadapter2.BR;

public class MsgDetailActivity extends CustomActivity<ActivityMsgDetailBinding, MsgDetailViewModel> {

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_msg_detail;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public MsgDetailViewModel initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(MsgDetailViewModel.class);
    }

    @Override
    public void initView() {
        super.initView();
        setOnRefresh(binding.refresh,REFRESH_0X3);

        setEnableLoadMore(Constants.GET_MSG_LIST);
        setEnableRefresh(Constants.GET_MSG_LIST);

        binding.comBack.setOnClickListener(view -> finish());

        binding.title.setText(getBundle().getString("titleName"));
    }

    @Override
    public void initData() {
        super.initData();

        viewModel.clearParams().setParams("msg_category_id",getBundle().getString("msg_category_id"));
        viewModel.requestData(Constants.GET_MSG_LIST);
    }

}
